<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>北京联合大学</title>
</head>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- <link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_xufba1hg66.css"> -->
<link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_uzbxo9d25is.css">
<link rel="stylesheet" href="../../css/Initialization.css">
<link rel="stylesheet" href="../../css/commen.css">
<link rel="stylesheet" href="../../css/UploadResults.css">
<body>
<div id="content">
    <div class="initer">
            <!-- 具体内容 -->
            <div class="bread">
                <div class="plain">
                    成立公司
                </div>
                <div class="plain">
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="plain current">
                    单元成绩管理
                </div>

                <div class="center-button" id="importAchievement">
                    单元成绩导入
                </div>
                <input type="hidden" th:value="${menu.getId()}" id="mid"/>
            </div>
            <div class="teacherlookwork teacherlookteam">
                <table class="table">
                    <tr class="tabletitle">
                        <td>序号</td>
                        <td>姓名</td>
                        <td>学号</td>
                        <td>组名</td>
                        <td>单元小组成绩</td>
                        <td>单元平时成绩</td>
                        <td>单元个人成绩</td>
                        <td>单元总成绩</td>
                    </tr>
                    <tr th:each="item : ${arraylist}">
                        <td th:text="${item.id}">序号</td>
                        <td th:text="${item.name}">姓名</td>
                        <td th:text="${item.userno}">学号</td>
                        <td th:text="${item.groupname}">组名</td>
                        <td class="green" th:text="${item.totalscore}">单元小组成绩</td>
                        <td class="green" th:text="${item.usualscore}">单元平时成绩</td>
                        <td class="green" th:text="${item.personscore}">单元个人成绩</td>
                        <td class="green" th:text="${item.groupscore}">单元总成绩</td>
                    </tr>
                </table>
                <!-- 分页 -->
                <div class="pages" th:utext="${pageResult.getPageHtml()}"></div>
            </div>
            <!-- 确认弹框 -->
            <div class="teacherlookteammask none">
                <div class="fileinput">
                    <div class="title">成绩单元导入</div>
                    <div class="tiptitle">
                        下载数据单元模板
                    </div>
                    <div class="tip">
                        说明：请下载数据模板并按照模板内容填写的数据后再上传导入
                    </div>
                    <div class="optionsbuttons">
                        <div class="center-button file">选择文件
                            <input type="file" name='file'>
                        </div>
                        <div class="center-button cancel">
                            取消导入
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <!-- 确认弹框 -->
    <div class="teacherlookteammask none">
        <div class="fileinput">
            <div class="title">单元成绩导入</div>
            <div class="tip">
                说明：请下载团队贡献评分导入并按照内容填写的数据后再上传导入
            </div>
            <div class="optionsbuttons">
                <div class="center-button file">选择文件
                    <input type="file" name='file' id="file">
                </div>
                <div class="center-button cancel" id="importCancel">
                    取消导入
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/commen.js"></script>
<script>
    $(function () {
        $("#importAchievement").click(function () {
            $('.teacherlookteammask').removeClass('none');
        });

        $("#importCancel").click(function () {
            $('.teacherlookteammask').addClass('none');
        })

        $("#file").change(function () {
            if($(this).val() != ""){
                var formData = new FormData();
                var mid = $("#mid").val();
                formData.append("file", document.getElementById("file").files[0]);
                formData.append("mid", mid);
                $.ajax({
                    url: "importAchievement",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    dataType:"json",
                    success: function (data) {
                        if(data.state == success){
                            alert("上传成功");
                            location.reload();
                        }else if(data.state == error){
                            alert(data.result);
                        }
                    },
                    error: function () {
                        alert("上传失败！");
                    }
                });
            }
        })
    })
</script>
</body>
</html>

